export function groupBoxesByWarehouseId(boxList) {
  const warehouseMap = new Map();
  for (const box of boxList) {
    const warehouseId = box.warehouse.id;
    let warehouseObj = warehouseMap.get(warehouseId);
    if (!warehouseObj) {
      // 如果该 warehouseId 对应的 warehouse 对象不存在，则创建一个新的
      warehouseObj = {
        ...box.warehouse,
        belongBoxList: [],
      };
      warehouseMap.set(warehouseId, warehouseObj);
    }
    // 将当前 box 添加到对应的 belongBoxList 中
    warehouseObj.belongBoxList.push(box);
  }
  // 将 Map 中的值转换为数组
  return Array.from(warehouseMap.values());
}
